<template>
	<view class="content">
		<view class="logo">
			<view class="title">
				<text>
					<text class="red">*</text>
					填写车名
				</text>
				<view class="input"><input type="text" v-model="param.name" placeholder="请填写车名" /></view>
			</view>
			<view class="title">
				<text>
					<text class="red">*</text>
					填写车牌
				</text>
				<u-keyboard ref="uKeyboard" mode="car" v-model="numPlte" @change="valChange" @backspace="backspace"></u-keyboard>
				<view class="input">
					<input type="text" v-model="param.plate" disabled placeholder="请填写车牌号" @click="this.numPlte = true" />
				</view>
			</view>

			<u-select v-model="brandShow" :list="list" @confirm="confirm" label-name="name" value-name="id"></u-select>
			<view class="title" @click="this.brandShow = true">
				<text>
					<text class="red">*</text>
					填写品牌
				</text>
				<view class="input"><input type="text" disabled v-model="brand" placeholder="请填写品牌 , 例如:宝马" /></view>
			</view>

			<u-select v-model="modelShow" :list="list1" @confirm="confirm1" label-name="name" value-name="id"></u-select>
			<view class="title" @click="this.modelShow = true">
				<text>
					<text class="red">*</text>
					填写车型
				</text>
				<view class="input"><input type="text" v-model="models" disabled placeholder="请填写车型 , 例如: 轿车" /></view>
			</view>

			<u-select v-model="aFewShow" :list="list2" @confirm="confirm2" label-name="name" value-name="id"></u-select>
			<view class="title" @click="this.aFewShow = true">
				<text>
					<text class="red">*</text>
					填写几座
				</text>
				<view class="input"><input disabled type="text" v-model="few" placeholder="请填写几座 , 例如: 二座" /></view>
			</view>
			<view class="title">
				<text>
					<text class="red">*</text>
					填写简介
				</text>
				<view class="input"><input type="text" v-model="param.brief" placeholder="请填写简介" /></view>
			</view>

			<view class="title">
				<text>
					<text class="red">*</text>
					填写租金
				</text>
				<view class="input"><input type="number" v-model="param.rent" placeholder="租金/天" /></view>
			</view>
			<view class="title">
				<text>
					<text class="red">*</text>
					划线金额
				</text>
				<view class="input"><input type="number" v-model="param.lineation" placeholder="划线金额/天" /></view>
			</view>
			<view class="title">
				<text>
					<text class="red">*</text>
					填写押金
				</text>
				<view class="input"><input type="number" v-model="param.deposit" placeholder="请填写押金" /></view>
			</view>
			<view class="title">
				<text>
					<text class="red">*</text>
					违章押金
				</text>
				<view class="input"><input type="number" v-model="param.illegal" placeholder="请填写违章押金" /></view>
			</view>
			<view class="title">
				<text>
					<text class="red">*</text>
					增值费用
				</text>
				<view class="input"><input type="number" v-model="param.cost" placeholder="请填写增值费用" /></view>
			</view>

			<view class="title">
				<text>
					<text class="red">*</text>
					成本价格
				</text>
				<view class="input"><input type="number" v-model="param.cost_price" placeholder="请填写成本价格" /></view>
			</view>
			<view class="title">
				<text>
					<text class="red">*</text>
					经销价格
				</text>
				<view class="input"><input type="number" v-model="param.dealer_price" placeholder="请添加经销商价格" /></view>
			</view>
			<view class="title" @click="getMap">
				<text>
					<text class="red">*</text>
					车辆地址
				</text>
				<view class="input"><input type="text" v-model="param.address" placeholder="请添加车辆所在地" /></view>
			</view>

			<view class="title">
				<text>
					<text class="red">*</text>
					上传封面
				</text>
			</view>
			<view class="upload">
				<view class="imgbox" v-for="(item, index) in fileList" :key="index" @click="changeImg(index)"><image :src="item"></image></view>
				<view class="addbox" @click="addImg(1)" v-if="fileList.length < fileListNum">
					<text class="add cuIcon-add"></text>
					<text style="margin-top: -30rpx;">添加照片</text>
				</view>
			</view>
			<view class="title">
				<text>
					<text class="red">*</text>
					上传主图
				</text>
			</view>
			<view class="upload">
				<view class="imgbox" v-for="(item, index) in mainImgLst" :key="index" @click="change1Img(index)"><image :src="item"></image></view>
				<view class="addbox" @click="addImg(2)" v-if="mainImgLst.length < fileListNum">
					<text class="add cuIcon-add"></text>
					<text style="margin-top: -30rpx;">添加照片</text>
				</view>
			</view>

			<!-- <view class="title">
				<text><text class="red">*</text>是否启动活动价 </text>
				<view class="input">
					<input type="number" v-model="param.lineation" placeholder="请输入限时活动价格/天" v-if="isChecked" />
					<input type="number" v-model="param.lineation" placeholder="请输入限时活动价格/天" disabled v-else/>
				</view>
			</view> -->
			<view class="title">
				<text style="margin-right:20rpx ;">
					<text class="red">*</text>
					是否启动活动 :
				</text>
				<view class="radio" @click="startEvnt(1)">
					<view class="box" :style="isChecked ? 'background-color:#880000' : ''"></view>
					<text>是</text>
				</view>
				<view class="radio" @click="startEvnt(0)">
					<view class="box" :style="isChecked ? '' : 'background-color:#880000'"></view>
					<text>否</text>
				</view>
			</view>
			
			
			
			
			<view class="date" v-if="activityTm" @click="opnEvnt(1)">
				<view class="left"><text>开始日期</text></view>
				<view class="right" v-if="!onetActivity">
					<text>{{ $u.timeFormat(+new Date(), 'yyyy-mm-dd hh:MM:ss') }}</text>
				</view>
				<view class="right" v-else>
					<text>{{ onetActivity }}</text>
				</view>
			</view>
			
			<view class="date" v-if="activityTm" @click="opnEvnt(0)">
				<view class="left"><text>结束时间</text></view>
				<view class="right" v-if="!twoActivity">
					<text>{{ $u.timeFormat(+new Date(), 'yyyy-mm-dd hh:MM:ss') }}</text>
				</view>
				<view class="right" v-else>
					<text>{{ twoActivity }}</text>
				</view>
			</view>
			
			
			<u-picker  v-model="isShowDt2" mode="time" :default-time="onetActivity" :params="params" @confirm="confirmSelection2()"></u-picker>
			
			<u-picker  v-model="isShowDt22" mode="time" :default-time="twoActivity" :params="params" @confirm="confirmSelection22()"></u-picker>




			<view class="title">
				<text style="margin-right:20rpx ;">
					<text class="red">*</text>
					是否推荐热门搜索 :
				</text>
				<view class="radio" @click="opnSrch(1)">
					<view class="box" :style="isSrchFor ? 'background-color:#880000' : ''"></view>
					<text>是</text>
				</view>
				<view class="radio" @click="opnSrch(0)">
					<view class="box" :style="isSrchFor ? '' : 'background-color:#880000'"></view>
					<text>否</text>
				</view>
			</view>
			
			
			
			
			<view class="title">
				<text style="margin-right:20rpx ;">
					<text class="red">*</text>
					车辆起租天数 :
				</text>
				<view class="radio" @click="opnDays(1)">
					<view class="box" :style="isDays ? 'background-color:#880000' : ''"></view>
					<text>半天</text>
				</view>
				<view class="radio" @click="opnDays(0)">
					<view class="box" :style="isDays ? '' : 'background-color:#880000'"></view>
					<text>全天</text>
				</view>
			</view>
		</view>

		<view class="setTime">
			<view class="title" style="display: flex;justify-content: space-between;">
				<text>
					<text class="red">*</text>
					长租优惠
				</text>
			</view>

			<view class="inputBox">
				<!-- <u-input type="input" border v-model="disc" placeholder="请输入长租优惠" />
				<view class="add" @click="addOffer">添加</view> -->

				<u-input type="input" border v-model="days" placeholder="请输入价格" height="50" />
				<text class="text">日租金 :&emsp;</text>
				<u-input type="input" border v-model="prc" placeholder="¥" height="50" />
				<text class="add" @click="addTo">添加</text>
			</view>

			<view style="height: 20rpx;"></view>

			<block v-for="(i, index11) in addLst" :key="index11">
				<view class="inputBox" style="margin-bottom: 10rpx;">
					<u-input type="input" placeholder="请输入价格" border border-color="#6E6E6E" height="30" :value="i[0]" />
					<text class="text">日租金 :&emsp;</text>
					<u-input type="input" placeholder="¥" border height="30" border-color="#6E6E6E" :value="i[1]" />
					<text class="add" @click="remove(index11)">移除</text>
				</view>
			</block>

			<!-- <block v-for="(i, index) in addLst" :key="index" v-else>
				<view class="inputBox" style="margin-bottom: 10rpx;">
					<u-input type="input" placeholder="请输入价格" border border-color="#6E6E6E" height="30" :value="i[0]" />
					<text class="text">日租金 :&emsp;</text>
					<u-input type="input" placeholder="¥" border height="30" border-color="#6E6E6E" :value="i[1]" />
					<text class="add" @click="remove(index)">移除</text>
				</view>
			</block> -->

			<!-- <u-input v-model="param.details" type="textarea" border height="300" /> -->

			<view class="title">
				<text>
					<text class="red">*</text>
					租用日历设置
				</text>
			</view>

			<u-picker
				v-if="oneTime"
				v-model="isShowDt1"
				mode="time"
				:default-time="oneTime"
				:params="params"
				@confirm="confirmSelection1()"
			></u-picker>
			<u-picker v-else v-model="isShowDt1" mode="time" :params="params" @confirm="confirmSelection1()"></u-picker>

			<u-picker v-if="twoTime" v-model="isShowDt" mode="time" :default-time="twoTime" :params="params" @confirm="confirmSelection()"></u-picker>
			<u-picker v-else v-model="isShowDt" mode="time" :params="params" @confirm="confirmSelection()"></u-picker>
			<view class="date" @click="turnOnPicker(1)">
				<view class="left"><text>开始日期</text></view>
				<view class="right" v-if="!oneTime">
					<text>{{ param.rent_time[0] }}</text>
				</view>
				<view class="right" v-else>
					<text>{{ oneTime }}</text>
				</view>
			</view>
			<view class="date" >
				<view class="left"><text>结束日期</text></view>
				<view class="right" v-if="!twoTime"  @click="turnOnPicker(0)">
					<text>{{ param.rent_time[1] }}</text>
					
				</view>
				<view class="right" v-else style="display: flex; justify-content: space-between;"  >
					<text @click="turnOnPicker(0)">{{ twoTime }}</text>
					<text style="margin-right: 50rpx;" @click="perm" v-if="id">永久</text>
				</view>
			</view>

			<view class="date" style="padding: 0; justify-content: space-between; background-color: #2a2929;" v-if="id">
				<view class="date" style="width: 30vw; text-align: center;" @click="saveTm">
					<view class="left" style="text-align: center; width: 100%;">保存时间</view>
				</view>
				<view class="date dd " @click="setCalSts()" style="width: 30vw; text-align: center;">
					<view class="left" style="text-align: center; width: 100%;">设置日历状态</view>
				</view>
			</view>
		</view>

		<view class="infomation">
			<view class="title">
				<text>
					<text class="red">*</text>
					下方固定信息列表填写
				</text>
			</view>

			<u-popup v-model="show11" mode="center" border-radius="14" width="500rpx" z-index="99999">
				<view class="vehIcon" v-for="(item, index) in total[0]" :key="index" @click="sel1(item.id, index)">
					<image :src="item.icon" mode=""></image>
					<text>图标{{ index + 1 }}</text>
				</view>
			</u-popup>

			<view class="vehIntroduction">
				<view class="one">
					<text class="text">车辆介绍</text>
					<text class="text1"></text>
				</view>
				<view class="editInfo">
					<view class="box" v-for="(item, index) in introduceList" :key="index">
						<view class="editImg" @click="editImg(index)">
							<image :src="item.icon" mode="" style="border-radius: 50%;" v-if="item.icon"></image>
							<image :src="item.icon" mode="" style="border-radius: 50%; border: 1rpx dashed #CCCCCC;" v-else></image>
						</view>
						<view class="editText"><input type="text" placeholder="编辑" v-model="item.name" /></view>
						<view class="solid"></view>
					</view>
				</view>
			</view>
			<view class="redHorzLine"><view class="red"></view></view>

			<u-popup v-model="show22" mode="center" border-radius="14" width="500rpx" z-index="99999">
				<view class="vehIcon" v-for="(item, index) in total[1]" :key="index" @click="sel2(item.id, index)">
					<image :src="item.icon" mode=""></image>
					<text>图标{{ index + 1 }}</text>
				</view>
			</u-popup>

			<view class="vehIntroduction">
				<view class="one">
					<text class="text">车辆保障</text>
					<text class="text1"></text>
				</view>
				<view class="editInfo">
					<view class="box" v-for="(item, index) in guarantee" :key="index">
						<view class="editImg" @click="editImg2(index)">
							<image :src="item.icon" mode="" v-if="item.icon" style="border-radius: 50%; "></image>
							<image :src="item.icon" mode="" v-else style="border-radius: 50%; border: 1rpx dashed #CCCCCC;"></image>
						</view>
						<view class="editText"><input type="text" placeholder="编辑" v-model="item.name" /></view>
						<view class="solid"></view>
					</view>
				</view>
			</view>
			<view class="redHorzLine"><view class="red"></view></view>

			<u-popup v-model="show33" mode="center" border-radius="14" width="500rpx" z-index="99999">
				<view class="vehIcon" v-for="(item, index) in total[2]" :key="index" @click="sel3(item.id, index)">
					<image :src="item.icon" mode=""></image>
					<text>图标{{ index + 1 }}</text>
				</view>
			</u-popup>

			<view class="vehIntroduction">
				<view class="one">
					<text class="text">特色服务</text>
					<text class="text1"></text>
				</view>
				<view class="editInfo">
					<view class="box" v-for="(item, index) in carServe" :key="index">
						<view class="editImg" @click="editImg3(index)">
							<image :src="item.icon" mode="" style="border-radius: 50% ;" v-if="item.icon"></image>
							<image :src="item.icon" mode="" style=" border-radius: 50%; border: 1rpx dashed #CCCCCC;" v-else></image>
						</view>
						<view class="editText"><input type="text" placeholder="编辑" v-model="item.name" /></view>
						<view class="solid"></view>
					</view>
				</view>
			</view>

			<u-popup v-model="show44" mode="center" border-radius="14" width="500rpx" z-index="99999">
				<view class="vehIcon" v-for="(item, index) in total[3]" :key="index" @click="sel4(item.id, index)">
					<image :src="item.icon" mode=""></image>
					<text>图标{{ index + 1 }}</text>
				</view>
			</u-popup>

			<view class="vehIntroduction">
				<view class="one">
					<text class="text">用车流程</text>
					<text class="text1"></text>
				</view>
				<view class="editInfo">
					<view class="box" v-for="(item, index) in process" :key="index">
						<view class="editImg" @click="editImg4(index)">
							<image :src="item.icon" mode="" style="border-radius: 50%;" v-if="item.icon"></image>
							<image :src="item.icon" mode="" style="border-radius: 50%; border: 1rpx dashed #CCCCCC;" v-else></image>
						</view>
						<view class="editText"><input type="text" placeholder="编辑" v-model="item.name" /></view>
						<view class="solid"></view>
					</view>
				</view>
			</view>
		</view>
		<view class="footer" v-if="id">
			<text class="textdd" @click="offShelf" v-if="shelves == 1">下架</text>
			<text class="textdd" @click="offShelf" v-if="shelves == 0">上架</text>
			<text class="textd" @click="submit(1)">更新车辆</text>
		</view>
		<view class="footer" @click="submit(2)" v-else>立即上传</view>
	</view>
</template>

<script>
import uploadImage from '../../common/ossutil/uploadFile.js';
export default {
	data() {
		return {
			numPlte: false,
			title: '',
			price: '',
			activiePrice: '',
			// 预置上传列表
			preList: [],
			fileList: [], // 封面
			mainImgLst: [], // 主图
			isShowDt: false,
			isShowDt1: false,
			isShowDt2: false,
			isShowDt22: false,
			fileListNum: 1,
			introduceList: [
				{
					icon: '',
					name: '',
					id: ''
				},
				{
					icon: '',
					name: '',
					id: ''
				},
				{
					icon: '',
					name: '',
					id: ''
				},
				{
					icon: '',
					name: '',
					id: ''
				},
				{
					icon: '',
					name: '',
					id: ''
				},
				{
					icon: '',
					name: '',
					id: ''
				}
			],
			guarantee: [
				{
					icon: '',
					name: '',
					id: ''
				},
				{
					icon: '',
					name: '',
					id: ''
				},
				{
					icon: '',
					name: '',
					id: ''
				}
			],
			carServe: [
				{
					icon: '',
					name: '',
					id: ''
				},
				{
					icon: '',
					name: '',
					id: ''
				},
				{
					icon: '',
					name: '',
					id: ''
				}
			],
			process: [
				{
					icon: '',
					name: '',
					id: ''
				},
				{
					icon: '',
					name: '',
					id: ''
				},
				{
					icon: '',
					name: '',
					id: ''
				}
			],
			infoList: [],
			infoListNum: 6,
			isChecked: false,
			isSrchFor: false,
			isDays: false,
			isDel: false,
			params: {
				year: true,
				month: true,
				day: true,
				hour: true,
				minute: true,
				second: true
			},
			status: '',
			param: {
				name: '', //车名-
				plate: '', //车牌号-
				brief: '', //简介-
				details: '', //详情-
				picture: '', //封面图-
				figure: '', //主图-
				brand: '', //品牌 -
				models: '', //车型-
				few: '', //几座-
				rent: '', //租金-
				lineation: '', //划线金额 -
				cost_price: '', //成本价 员工通道-
				dealer_price: '', //经销商价格-
				deposit: '', //押金-
				illegal: '', //违章押金-
				cost: '', //增值费用-
				is_activity: 0, //开启活动 1开启 0关闭-
				discount_time: [], // 活动时间 [2020-11-18 00:00:00,2020-11-30 00:00:00]
				rent_time:[],
				address: '', //车辆所在地-
				//shelves:"1",  //上下架 单选 1上架 0下架
				is_search: 0, //推荐搜索 单选 1推荐 0未推荐-
				rent_num: '全天', //起租天数 单选 半天 全天-
				introduce: [], // 车辆介绍 [1,2]
				security: [], // 车辆保障 [1,2]
				service: [], // 特色服务 [1,2]
				process: [] // 用车流程 [1,2]
			},
			id: '',
			oneTime: '',
			twoTime: '',
			onetActivity: '',
			twoActivity: '',
			shelves: '',
			brandShow: false,
			modelShow: false,
			aFewShow: false,
			list: [],
			list1: [],
			list2: [],
			days: '',
			prc: '',
			brand: '',
			models: '',
			few: '',
			total: [],
			show11: false,
			show22: false,
			show33: false,
			show44: false,
			activityTm: false,
			i1: '',
			i2: '',
			i3: '',
			i4: '',
			addLst: [],
			
		};
	},
	onLoad(id) {
		console.log('id :>> ', id);
		this.id = id.id;
		this.garageScreening();
		if (id.id) {
			this.getVehData(id.id);
			//this.oneTime = this.$u.timeFormat(+new Date(), 'yyyy-mm-dd hh:MM:ss');
			//this.param.rent_time[0] = this.$u.timeFormat(+new Date(), 'yyyy-mm-dd hh:MM:ss');
			//this.param.rent_time[1] = this.$u.timeFormat(+new Date(), 'yyyy-mm-dd hh:MM:ss');
		} else {
			this.getVehData1(1);
			this.param.discount_time[0] = this.$u.timeFormat(+new Date(), 'yyyy-mm-dd hh:MM:ss');
			this.param.discount_time[1] = this.$u.timeFormat(+new Date(), 'yyyy-mm-dd hh:MM:ss');
			this.param.rent_time[0] = this.$u.timeFormat(+new Date(), 'yyyy-mm-dd hh:MM:ss');
			this.param.rent_time[1] = this.$u.timeFormat(+new Date(), 'yyyy-mm-dd hh:MM:ss');
			//this.oneTime = this.$u.timeFormat(+new Date(), 'yyyy-mm-dd hh:MM:ss');
		}
	},

	methods: {
		async getMap() {
				const res = await uni.chooseLocation();
				this.param.address = res[1].address
				console.log('res',res);
		},
		async perm(){
			console.log('this.oneTime :>> ', this.oneTime);
			
			this.param.details = this.addLst;
			
			this.param.rent_time = `${this.oneTime}`;
			if (!Number(this.param.brand)) return uni.$showMsg('请重新选择品牌');
			if (!Number(this.param.models)) return uni.$showMsg('请重新选择车型');
			if (!Number(this.param.few)) return uni.$showMsg('请重新选择几座');
			delete this.param.car_alias;
			delete this.param.back;
			delete this.param.hot_back;
			delete this.param.photo;
			console.log('this.param :>> ', this.param);
			for (let key in this.param) {
				console.log('key :>> ', this.param[key]);
				if (typeof this.param[key] === 'string') {
					console.log('字符串');
					if (this.param[key].length == 0) {
						console.log('key :>> ', key);
						return uni.$showMsg('不能为空');
					}
				}
				if (this.param[key] instanceof Array) {
					console.log('数组');
					if (this.param[key].length == 0) {
						console.log('key :>> ', key);
			
						return uni.$showMsg('不能为空');
					}
				}
			}
			
			console.log(' this.param :>> ', this.param);
			const res = await this.$u.post('api/set/car_update', this.param);
			if (!res.code) return uni.$showMsg(res.msg);
			uni.$showMsg(res.msg);
			
			
			
		},
		
		
		
		async saveTm() {
			
			
			this.param.details = this.addLst;
			this.param.rent_time = `${this.oneTime},${this.twoTime}`;
			if (!Number(this.param.brand)) return uni.$showMsg('请重新选择品牌');
			if (!Number(this.param.models)) return uni.$showMsg('请重新选择车型');
			if (!Number(this.param.few)) return uni.$showMsg('请重新选择几座');
			delete this.param.car_alias;
			delete this.param.back;
			delete this.param.hot_back;
			delete this.param.photo;
			console.log('this.param :>> ', this.param);
			for (let key in this.param) {
				console.log('key :>> ', this.param[key]);
				if (typeof this.param[key] === 'string') {
					console.log('字符串');
					if (this.param[key].length == 0) {
						console.log('key :>> ', key);
						return uni.$showMsg('不能为空');
					}
				}
				if (this.param[key] instanceof Array) {
					console.log('数组');
					if (this.param[key].length == 0) {
						console.log('key :>> ', key);

						return uni.$showMsg('不能为空');
					}
				}
			}

			console.log(' this.param :>> ', this.param);
			const res = await this.$u.post('api/set/car_update', this.param);
			if (!res.code) return uni.$showMsg(res.msg);
			uni.$showMsg(res.msg);
		},

		addTo() {
			if (this.days == '' || this.prc == '') {
				return uni.$showMsg('不能为空');
			}
			let arr = [this.days, this.prc];
			console.log('arr :>> ', arr);
			(this.addLst = [...this.addLst, arr]), (this.days = '');
			this.prc = '';
			console.log('this.addLst :>> ', this.addLst);
		},
		remove(index) {
			console.log('index :>> ', index);
			//delete this.addLst[index]
			this.addLst.splice(index, 1);
		},
		valChange(val) {
			this.param.plate += val;
			console.log(this.param.plate);
		},

		backspace() {
			if (this.param.plate.length) this.param.plate = this.param.plate.substr(0, this.param.plate.length - 1);
			console.log(this.param.plate);
		},
		setCalSts() {
			uni.navigateTo({
				url: '../selCal/selCal?cid=' + this.id
			});
		},
		async getVehData1(id) {
			const res = await this.$u.post('api/user/user_admin_edit', { cid: id });
			this.total = res.total;
		},
		addOffer() {
			this.param.details = `${this.param.details}${this.disc} `;
			this.disc = '';
		},
		confirm(e) {
			console.log('e :>> ', e);
			this.brand = e[0].label;
			this.param.brand = e[0].value;
		},
		confirm1(e) {
			console.log('e :>> ', e);
			this.models = e[0].label;
			this.param.models = e[0].value;
		},
		confirm2(e) {
			console.log('e :>> ', e);
			this.few = e[0].label;
			this.param.few = e[0].value;
		},
		async offShelf() {
			const res = await this.$u.post('api/user/user_car_shelves', {
				cid: this.id
			});
			console.log('res :>> ', res);
			uni.navigateBack({
				delta: 1
			});
			uni.$showMsg(res.msg);
		},
		async garageScreening() {
			const res = await this.$u.post('api/car/car_screen');
			console.log('筛选 :>> ', res);
			this.list = res.data[0].secondary; // 品牌
			this.list1 = res.data[1].secondary; // 车型
			this.list2 = res.data[2].secondary; // 几座
		},

		//获取车辆数据
		async getVehData(id) {
			const res = await this.$u.post('api/user/user_admin_edit', {
				cid: id
			});
			console.log('获取车辆数据 >>  ', res);
			this.addLst = res.data.details;
			this.param = res.data;
			if (res.data.rent_time.length==0) {
				this.param.rent_time[0] = this.$u.timeFormat(+new Date(), 'yyyy-mm-dd hh:MM:ss');
				this.param.rent_time[1] = this.$u.timeFormat(+new Date(), 'yyyy-mm-dd hh:MM:ss');
			}
			console.log('this.param :>> ', this.param);
			
			//
			this.brand = res.data.brand;
			this.models = res.data.models;
			this.few = res.data.few;
			this.list.forEach(i => {
				if (i.name == res.data.brand) {
					this.param.brand = i.id;
					console.log('this.param.brand  :>> ', this.param.brand);
				}
			});
			this.list1.forEach(i => {
				if (i.name == res.data.models) {
					this.param.models = i.id;
				}
			});
			this.list2.forEach(i => {
				if (i.name == res.data.few) {
					this.param.few = i.id;
				}
			});

			//
			if (res.data.is_activity == 1) {
				this.isChecked = true;
			} else {
				this.isChecked = false;
			}
			if (res.data.is_search == 1) {
				this.isSrchFor = true;
			} else {
				this.isSrchFor = false;
			}
			if (res.data.rent_num == '半天') {
				this.isDays = true;
			} else {
				this.isDays = false;
			}

			this.total = res.total;
			console.log('this.total :>> ', this.total);
			this.shelves = res.data.shelves;
			this.fileList = [res.data.picture];
			this.mainImgLst = [res.data.figure];
			//let arr = res.data.discount_time.split(',');
			//this.oneTime = res.data.rent_time[0];   
			this.oneTime = res.data.rent_time[0];   //discount_time
			this.twoTime = res.data.rent_time[1];
			//is_activity
			
			if (res.data.is_activity) {
				this.activityTm = true
			}
			
			
			
			// 活动时间 onetActivity
			this.onetActivity = res.data.discount_time[0];
			this.twoActivity = res.data.discount_time[1];
			console.table('res.data.introduce :>> ', res.data.introduce);
			if (res.data.introduce.length !== 0) {
				console.log('进入了: ');
				this.introduceList = res.data.introduce;
			}
			if (res.data.security.length !== 0) {
				this.guarantee = res.data.security;
			}
			if (res.data.service.length !== 0) {
				this.carServe = res.data.service;
			}
			if (res.data.process.length !== 0) {
				this.process = res.data.process;
			}
		},
		// 添加车辆
		async addVeh() {
			const res = await this.$u.post('api/set/car_add', {
				uid: this.uid
			});
			console.log('res >>  ', res);
		},
		confirmSelection1(e) {
			this.oneTime = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute + ':' + e.second;
			console.log('this.oneTime  :>> ', this.oneTime);
			this.param.rent_time[0] = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute + ':' + e.second;
		},
		confirmSelection(e) {
			this.twoTime = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute + ':' + e.second;
			this.param.rent_time[1] = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute + ':' + e.second;
		},
		
		
		
		confirmSelection2(e) {
			
			this.onetActivity = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute + ':' + e.second;
			console.log('this.onetActivity  :>> ', this.onetActivity);
			this.param.discount_time[0] = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute + ':' + e.second;
		},
		confirmSelection22(e) {
			this.twoActivity = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute + ':' + e.second;
			this.param.discount_time[1] = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute + ':' + e.second;
		},
		opnEvnt(i){
			if (i) {
				this.isShowDt2 = true;
			} else {
				this.isShowDt22 = true;
			}
		},
		
		turnOnPicker(i) {
			if (i) {
				this.isShowDt1 = true;
			} else {
				this.isShowDt = true;
			}
		},
		// 开启活动
		startEvnt(i) {
			if (i) {
				this.isChecked = true;
				this.activityTm = true;
				this.param.is_activity = 1;
			} else {
				this.isChecked = false;
				this.activityTm = false;
				this.param.is_activity = 0;
			}
		},
		//开启搜索
		opnSrch(i) {
			if (i) {
				this.isSrchFor = true;
				this.param.is_search = 1;
			} else {
				this.isSrchFor = false;
				this.param.is_search = 0;
			}
		},
		//天数
		opnDays(i) {
			if (i) {
				this.isDays = true;
				this.param.rent_num = '半天';
				console.log('this.param.rent_num :>> ', this.param.rent_num);
			} else {
				this.isDays = false;
				this.param.rent_num = 0;
				this.param.rent_num = '全天';
				console.log('this.param.rent_num :>> ', this.param.rent_num);
			}
		},
		addImg(i) {
			if (i == 1) {
				uni.chooseImage({
					count: 1,
					sourceType: ['album '],
					success: res => {
						// console.log('res2 :>> ', res);
						this.fileList = res.tempFilePaths;
						// this.param.picture = res.tempFilePaths[0];
						// var tempFilePaths = res.tempFilePaths;

						for (var i = 0; i < res.tempFilePaths.length; i++) {
							uni.showLoading({
								mask: true
							});
							uploadImage(res.tempFilePaths[0], 'car/', result => {
								console.log('result 11:>> ', result);

								this.param.picture = result;

								uni.hideLoading();
							});
						}
					}
				});
			} else {
				uni.chooseImage({
					count: 1,
					sourceType: ['album '],
					success: res => {
						console.log('res 3:>> ', res);
						this.mainImgLst = res.tempFilePaths;
						//var tempFilePaths = res.tempFilePaths;
						//this.param.figure = res.tempFilePaths[0];

						for (var i = 0; i < res.tempFilePaths.length; i++) {
							uni.showLoading({
								mask: true
							});

							uploadImage(res.tempFilePaths[i], 'car/', result => {
								this.param.figure = result;
								uni.hideLoading();
							});
						}
					}
				});
			}
		},

		// 封面
		changeImg(i) {
			uni.chooseImage({
				count: 1,
				sourceType: ['album '],
				success: res => {
					console.log('res4 :>>>> ', res);
					this.fileList = res.tempFilePaths;
					//this.param.picture = res.tempFilePaths[0];
					//var tempFilePaths = res.tempFilePaths;

					for (var i = 0; i < res.tempFilePaths.length; i++) {
						uni.showLoading({
							mask: true
						});
						uploadImage(res.tempFilePaths[i], 'car/', result => {
							this.param.picture = result;
							uni.hideLoading();
						});
					}
				}
			});
		},
		// 主图
		change1Img(i) {
			uni.chooseImage({
				count: 1,
				sourceType: ['album '],
				success: res => {
					console.log('res22 :>> ', res);
					this.mainImgLst = res.tempFilePaths;
					//var tempFilePaths = res.tempFilePaths;
					//this.param.figure = res.tempFilePaths[0];

					for (var i = 0; i < res.tempFilePaths.length; i++) {
						uni.showLoading({
							mask: true
						});

						uploadImage(res.tempFilePaths[i], 'car/', result => {
							this.param.figure = result;
							uni.hideLoading();
						});
					}
				}
			});
		},
		sel1(id, index) {
			this.show11 = false;
			let test = this.total[0];
			this.introduceList[this.i1].icon = test[index].icon;
			this.introduceList[this.i1].id = id;
			this.param.introduce = this.introduceList;
		},
		editImg(i) {
			this.i1 = i;
			this.show11 = true;
		},
		sel2(id, index) {
			this.show22 = false;
			let test = this.total[1];
			this.guarantee[this.i2].icon = test[index].icon;
			this.guarantee[this.i2].id = id;
			this.param.security = this.guarantee;
		},
		editImg2(i) {
			this.i2 = i;
			this.show22 = true;
		},

		sel3(id, index) {
			this.show33 = false;
			let test = this.total[2];
			this.carServe[this.i3].icon = test[index].icon;
			this.carServe[this.i3].id = id;
			this.param.service = this.carServe;
		},

		editImg3(i) {
			this.i3 = i;
			this.show33 = true;
		},
		sel4(id, index) {
			this.show44 = false;
			let test = this.total[3];
			console.log('this.total[3] :>> ', this.total[3]);
			this.process[this.i4].icon = test[index].icon;
			this.process[this.i4].id = id;
			this.param.process = this.process;
		},

		editImg4(i) {
			this.i4 = i;
			this.show44 = true;
		},

		async submit(e) {
			this.param.details = this.addLst;
			// if (!this.param.rent_time[0]) {
			// 	this.param.rent_time[0] = this.$u.timeFormat(+new Date(), 'yyyy-mm-dd hh:MM:ss');
			// }
			// if (!this.param.discount_time[0]) {
			// 	this.param.discount_time[0] = this.$u.timeFormat(+new Date(), 'yyyy-mm-dd hh:MM:ss');
			// }
			this.param.rent_time = `${this.oneTime},${this.twoTime}`
			//this.param.discount_time =  `${this.onetActivity},${this.twoActivity}`
			if (!Number(this.param.brand)) return uni.$showMsg('请重新选择品牌');
			if (!Number(this.param.models)) return uni.$showMsg('请重新选择车型');
			if (!Number(this.param.few)) return uni.$showMsg('请重新选择几座');
			delete this.param.car_alias;
			delete this.param.back;
			delete this.param.hot_back;
			delete this.param.photo; 
		
			console.log('this.param :>> ', this.param);
			for (let key in this.param) {
				console.log('key :>> ', this.param[key]);
				if (typeof this.param[key] === 'string') {
					console.log('字符串');
					if (this.param[key].length == 0) {
						console.log('key :>> ', key);
						return uni.$showMsg('不能为空');
					}
				}
				if (this.param[key] instanceof Array) {
					console.log('数组');
					if (this.param[key].length == 0) {
						console.log('key :>> ', key);

						return uni.$showMsg('不能为空');
					}
				}
			}

			if (e == 2) {
				const res = await this.$u.post('api/set/car_add', this.param);

				if (!res.code) return uni.$showMsg(res.msg);
				// uni.navigateTo({
				// 	url: '../carList/carList'
				// });
				uni.navigateBack();
				uni.$showMsg(res.msg);
			} else {
				console.log(' this.param :>> ', this.param);
				const res = await this.$u.post('api/set/car_update', this.param);
				if (!res.code) return uni.$showMsg(res.msg);
				// uni.navigateTo({
				// 	url: '../carList/carList'
				// });
				uni.navigateBack();
				uni.$showMsg(res.msg);
			}
		}
	}
};
</script>

<style lang="scss">
.content {
	padding: 20rpx;
	padding-bottom: 120rpx;
	/deep/.u-input__input {
		color: #ffffff !important;
	}
	.red {
		color: #880000;
	}
	.interlayer {
		color: #ffffff;
	}
	.u-keyboard-grids-btn {
		background-color: #000000 !important;
	}
	// .u-drawer__scroll-view {
	// 	background-color: #2a2929;
	// 	padding: 20rpx;
	// }
	.vehIcon {
		width: 100%;
		height: 100rpx;
		display: flex;
		flex-wrap: wrap;
		justify-content: flex-start;
		align-items: center;
		border-bottom: 1rpx solid #cccccc;
		image {
			margin-left: 50rpx;
			width: 70rpx;
			height: 70rpx;
		}
		text {
			margin-left: 50rpx;
			color: #cccccc;
			font-size: 25rpx;
		}
	}
	.date {
		background-color: #242424;
		border-radius: 15rpx;
		padding: 10rpx;
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 10rpx;
	
		.right {
			flex: 2;
		}
	
		.left,
		.right {
			padding: 15rpx;
			line-height: 50rpx;
			color: #dadada;
		}
	}
	.title {
		height: 80rpx;
		display: flex;

		align-items: center;
		color: #fff;

		text {
			font-size: 30rpx;
		}

		.input {
			margin-left: 20rpx;
			font-weight: 0;
			border-bottom: 1rpx solid #6e6e6e;
			color: #6e6e6e;
			flex: 2;
		}

		.radio {
			display: flex;
			align-items: center;
			margin-right: 40rpx;

			.box {
				width: 35rpx;
				height: 35rpx;
				border-radius: 50%;
				border: 2rpx solid #880000;
				margin-right: 10rpx;
				text-align: center;
				line-height: 28rpx;
			}
		}
	}

	.upload {
		padding-bottom: 20rpx;
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
		text-align: center;

		.imgbox {
			height: 190rpx;
			width: 49%;
			background-color: #404040;
			border-radius: 20rpx;
			overflow: hidden;
			margin-bottom: 20rpx;

			image {
				width: 100%;
				height: 190rpx;
			}
		}

		.addbox {
			height: 190rpx;
			width: 49%;
			background-color: #404040;
			border-radius: 20rpx;
			color: #535353;
			display: flex;
			flex-direction: column;
			align-items: center;
			margin-bottom: 20rpx;

			.add {
				font-size: 150rpx;
			}
		}
	}

	.logo {
		padding: 20rpx;
		background-color: #2a2929;
		border-radius: 10rpx;
		color: #fff;
	}

	.setTime {
		margin-top: 20rpx;
		padding: 20rpx;
		background-color: #2a2929;
		border-radius: 10rpx;
		.inputBox {
			display: flex;
			align-items: center;

			/deep/.u-input {
				width: 30vw !important;
				margin-right: 15rpx;
			}
			.text,
			.add {
				color: #ffffff;
			}
			.add {
			}
		}
		.preTime {
			display: flex;
			margin-bottom: 10rpx;
			line-height: 40rpx;
			justify-content: space-between;

			.preDate {
				margin-right: 10rpx;
				display: flex;
				flex: 4.5;
				color: #6e6e6e;
				font-size: 24rpx;

				input {
					flex: 1;
				}
			}

			border-bottom: 1rpx solid #6e6e6e;

			.del {
				flex: 1;
				color: #880000;
			}
		}
		.dd {
			display: flex;
			justify-content: space-between;
			align-items: center;
			color: #dadada;
		}
		.date {
			background-color: #242424;
			border-radius: 15rpx;
			padding: 10rpx;
			width: 100%;
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 10rpx;

			.right {
				flex: 2;
			}

			.left,
			.right {
				padding: 15rpx;
				line-height: 50rpx;
				color: #dadada;
			}
		}
	}
	
	.infomation {
		margin-top: 20rpx;
		.u-drawer__scroll-view {
			background-color: #2a2929;
			padding: 20rpx;
		}
		.redHorzLine {
			position: relative;
			width: 653rpx;
			border-bottom: 1rpx solid #141414;
			margin: 0 auto;

			.red {
				position: absolute;
				top: 0;
				left: 50%;
				transform: translateX(-50%);
				width: 122rpx;
				height: 2rpx;
				background-color: #880000;
			}
		}

		padding: 20rpx;
		background-color: #2a2929;
		border-radius: 10rpx;

		.vehIntroduction {
			position: relative;
			padding: 49rpx 0;

			.one {
				position: relative;
				display: flex;
				justify-content: center;
				align-items: center;
				height: 36rpx;

				.text {
					position: absolute;
					bottom: 0;
					left: 50%;
					transform: translateX(-50%);
					height: 36rpx;
					font-size: 36rpx;
					font-family: Microsoft YaHei;
					font-weight: 400;
					color: #ffffff;
					line-height: 36rpx;
					z-index: 11;
				}

				.text1 {
					position: absolute;
					bottom: -5rpx;
					left: 50%;
					transform: translateX(-50%);
					width: 162rpx;
					height: 15rpx;
					background: #880000;
					border-radius: 7rpx;
				}
			}
			.editInfo {
				display: flex;
				flex-wrap: wrap;
				.box {
					margin-top: 50rpx;
					display: flex;
					width: 33%;
					flex-direction: column;
					align-items: center;
					.editImg {
						width: 80rpx;
						height: 80rpx;
						image {
							width: 100%;
							height: 100%;
						}
					}
					.editText {
						color: #ffffff;
						text-align: center;
						font-size: 24rpx;
						padding: 10rpx;
					}
					.solid {
						width: 80rpx;
						height: 5rpx;
						background-color: #fff;
						border-radius: 5rpx;
					}
					&:nth-child(2) {
						border-left: 2rpx solid #ffffff;
						border-right: 2rpx solid #ffffff;
					}
					&:nth-child(5) {
						border-left: 2rpx solid #ffffff;
						border-right: 2rpx solid #ffffff;
					}
				}
			}
		}
	}
}

.carInfoImg {
	margin: 20rpx 0 100rpx 0;
	padding: 20rpx;
	background-color: #2a2929;
	border-radius: 10rpx;
}

.footer {
	position: fixed;
	left: 0;
	bottom: 0;
	height: 100rpx;
	width: 100%;
	background-color: #880000;
	color: #fff;
	font-size: 35rpx;
	text-align: center;
	line-height: 100rpx;
	z-index: 999;
	display: flex;
	justify-content: center;
	align-items: center;
	.textdd {
		flex: 1;
		width: 100%;
		justify-content: center;
	}
	.textd {
		flex: 2;
		width: 100%;
		justify-content: center;
		color: #880000;
		background-color: #dcdcdc;

		font-size: 38rpx;
		font-family: Microsoft YaHei;
		font-weight: bold;
		color: #880000;
	}
}
</style>
